package com.persondemo.videoappliction.ui.search.presenter;

import com.persondemo.videoappliction.bean.HotSearchBean;
import com.persondemo.videoappliction.net.BaseApi;
import com.persondemo.videoappliction.net.BaseObserver;
import com.persondemo.videoappliction.net.RxSchedulers;
import com.persondemo.videoappliction.ui.base.BasePresenter;
import com.persondemo.videoappliction.ui.search.contract.FSContract;

import javax.inject.Inject;

/**
 * Created by Administrator on 2018/4/16.
 */

public class FSPresenter extends BasePresenter<FSContract.View> implements FSContract.presenter {
    BaseApi baseApi;
    @Inject
    public FSPresenter(BaseApi baseApi) {
        this.baseApi = baseApi;
    }

    @Override
    public void getseachdata(String key, int page) {
        baseApi.fragmentbiaoqian(key, page)
                .compose(RxSchedulers.applySchedulers())
                .compose(mView.bindToLife())
                .subscribe(new BaseObserver<HotSearchBean>() {
                    @Override
                    public void onSuccess(HotSearchBean hotSearchBean) {
                        mView.loaddata(hotSearchBean);
                    }
                    @Override
                    public void onFail(Throwable e) {
                        mView.showFaild();
                    }
                });
    }
}
